package com.fy.market.persistent.mapper;

import cn.bugstack.middleware.db.router.annotation.DBRouter;
import cn.bugstack.middleware.db.router.annotation.DBRouterStrategy;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fy.market.persistent.po.RaffleActivityOrder;
import com.fy.market.persistent.po.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 用户 Mapper 接口
 * @author fwq
 * @date 2025-09-04
 * @desc 用户表 Mapper 接口
 */
@Mapper
@DBRouterStrategy(splitTable = true)
public interface UserMapper extends BaseMapper<User> {

    @DBRouter(key = "account")
    @Insert("insert into user (nick_name, account, password, avatar_url, last_login_time, status, role, deleted, create_time, update_time) " +
            "values (#{nickName}, #{account}, #{password}, #{avatarUrl}, #{lastLoginTime}, #{status}, #{role}, #{deleted}, #{createTime}, #{updateTime})")
    void add(User user);

    @DBRouter
    @Select("select * from user where account = #{account}")
    List<User> get(String account);
}